package com.itheima.stock.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 定义rabbitmy相关配置
 */
@Configuration
public class MqConfig {

    /**
     * 声明序列化模式
     * @return
     */
    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }


//    消息发送者已经定义了队列和交互机的相关信息
//    /**
//     * 定义主题交换机
//     * @return
//     */
//    @Bean
//    public TopicExchange stockTopicExchange(){
//        return new TopicExchange("stockExchange",true,false);
//
//    }
//
//    /**
//     * 定义队列
//     * @return
//     */
//    @Bean
//    public Queue innerMarketQueue(){
//        return new Queue("innerMarketQueue",true);
//    }
//
//    /**
//     * 绑定国内大盘队列到股票主题交换机
//     * @return
//     */
//    @Bean
//    public Binding bingdingInnerMarketQueue(){
//        return BindingBuilder.bind(innerMarketQueue()).to(stockTopicExchange()).with("inner.market");
//    }

}
